Crate atelier_json[−][src]
Expand description
Reads and writes the JSON AST representation described in the specification.
As that there is no separate model-level namespace, all shape names have been made absolute in this representation. This is a problem when constructing the model, if there are shapes from different namespaces present the parser will return an error at this time.
Example
The following JSON demonstrates the structure of the AST format.
{
"smithy": "1.0",
"metadata": {
"authors": [
"Simon"
]
},
"shapes": {
"smithy.example#MyString": {
"type": "string",
"traits": {
"smithy.api#documentation": "My documentation string",
"smithy.api#tags": [
"a",
"b"
]
}
},
"smithy.example#MyList": {
"type": "list",
"member": {
"target": "smithy.api#String"
}
},
"smithy.example#MyStructure": {
"type": "structure",
"members": {
"stringMember": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": {}
}
},
"numberMember": {
"target": "smithy.api#Integer"
}
}
}
}
}
The following will parse the model above.
use atelier_core::io::read_model_from_string; use atelier_json::JsonReader; let mut reader = JsonReader::default(); let result = read_model_from_string(&mut reader, JSON); if result.is_err() { println!("{:?}", result); } assert!(result.is_ok()); println!("{:#?}", result.unwrap());
Structs
Constants
The extension to use when reading from, or writing to, files of this type.
The name to report in errors in this representation.
Functions
Return a JSON AST representation
of a model. The return value is a [Serde JSON/(https://docs.serde.rs/serde_json/) Value
that
represents the top-level model.